/**
 * Definition for a binary tree node.
 * type TreeNode struct {
 *     Val int
 *     Left *TreeNode
 *     Right *TreeNode
 * }
 */
 // 递归
var maxDepth int
var value int

func findBottomLeftValue(root *TreeNode) int {
    if root.Left == nil && root.Right == nil {
        return root.Val
    }
    findLeftValue(root, maxDepth)
    return value
}

func findLeftValue(node *TreeNode, depth int){
    if node.Left == nil && node.Right == nil {
        if depth > maxDepth {
            maxDepth = depth
            value = node.Val
        }
    }
    if node.Left != nil {
        depth++
        findLeftValue(node.Left, depth)
        depth--
    }
    if node.Right != nil {
        depth++
        findLeftValue(node.Right, depth)
        depth--
    }
}